//返回值为需不需要关闭窗口
function yesOperator(){
    console.log("====yesOperator=====");
  var retValue=addData();
  return retValue;
}
function updateLoad(){
    var params = $$.getQueryString();
    $$.ajax({
        url:"/rest/IotPointCatalogBusiness/query",
        data : {
            id : params.rowId
        },
        success : function(data){
        	               $("#b_id").val(data.id);
                           $("#b_pid").val(data.pid);

                           $("#b_catalogName").val(data.catalogName);

                           $("#b_level").val(data.level);

                           $("#b_isLeaf").val(data.isLeaf);

                           $("#b_status").val(data.status);

                           $("#b_rowSort").val(data.rowSort);

                           $("#b_remarks").val(data.remarks);


                 var status=data.status; 

            $("input[name^='b_status_']").each(function(){
                    if($(this).val()==status){
                         this.checked='checked';
                    }
            });



            $("#b_point_sortCodeOld").val(data.point_sortCode);
           


        }
    });



}
function validForm(){
    return $("#theform").valid();

	 
    /*
    //判断编码唯一性
    if(!notNull("b_point_sortCode","采集点分类编码")){
        return false;
    }
    var point_sortCodeOld=$("#b_point_sortCodeOld").val();
    var point_sortCode=$("#b_point_sortCode").val();
    if(point_sortCodeOld==point_sortCode){

    }else{

            var args={};
            args.c_point_sortCode_1=$("#b_point_sortCode").val();
            args.page=0;
            args.pageSize=5;
            args.isPage=1;


            var exists;
            $$.ajax({
                url: "/bootstrap/basegrid/IotPointCatalogBusiness/list",
                async:false,
                data: args,
                success: function (data) {
                    if(data.length && data.length>0){
                        exists=true;
                     }else{
                        exists=false;
                    }
                }
            });
            if(exists){
               $$.alert("采集点分类编码已经存在,请重新输入!",function(index){
                   layer.close(index);
                   $("#b_point_sortCode").focus();
               });
               return false;
             }

    }
    */
    return true;
}
function addData(){
    console.log("====addData=====");
    var param = {};
    var validFormRet;
    $$.form({
        async:false,
        able:function(){
            validFormRet=false;
        },
        checkForm: validForm,
        success: function () {
            validFormRet= true;
        }
    });
    return validFormRet;
}
function formValid() {
    $("#theform").validate({
        rules: {
            b_catalogName: {
                required: true
            }

        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        errorElement: "span",
        errorClass: "errortips",
        success: 'valid',
        messages: {
            b_catalogName: {
                required: " (必填)"
            }
        },
    });
}


$(function () {
    formValid();
    $("input[name^='b_status']").click(function(){
        $("#b_status").val($(this).val());
    });
});
